<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <include file="Public:header" />

</head>
<body>
  <include file="Public:body_top" />

  <div class="container-fluid">
    <div class="row">
      <div class="col-sm-3 col-md-2 sidebar hidden-xs">
        <div class="menu">
          <dl>
            <dt><i class="cm-order"></i>小程序</dt>
            <dd><a href="{:U('Apps/xcx_edit')}">小程序配置</a></dd>
            <dd><a href="{:U('Apps/xcx_edit')}&tpl=xcx_msg_edit">小程序模板消息</a></dd>
            <dd><a href="{:U('Apps/xcx_edit')}&tpl=storage">存储配置</a></dd>
            <dd><a href="{:U('Apps/xcx_edit')}&tpl=sms">短信配置</a></dd>
            <dd><a href="{:U('Apps/xcx_edit')}&tpl=withdraw">提现配置</a></dd>
            <dd class="active"><a href="{:U('Mode/index')}">首页模式图标</a></dd>
          </dl>
          <dl>
            <dt><i class="cm-advert"></i>广告管理</dt>
            <dd><a href="{:U('Adverts/index')}">广告列表</a></dd>
            <dd><a href="{:U('Adverts/add')}">新建广告</a></dd>
          </dl>
          <dl>
            <dt><i class="icon-uniE611"></i>帮助管理</dt>
            <dd><a href="{:U('Helps/index')}">帮助列表</a></dd>
            <dd><a href="{:U('Helps/add')}">新建帮助</a></dd>
          </dl>
        </div>
      </div>
      <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
        <div class="main-hd">
          <h5>编辑商品</h5>
        </div>
        <div class="main-bd">
          <div class="form-box">
            <form class="form-horizontal" method="post" enctype="multipart/form-data" action="{:U('mode/editSubmit')}">
              <div class="form-group">
                <label class="col-sm-2 control-label">图标名称</label>
                <div class="col-sm-4">
                  <input type="text" class="form-control" name="name" value="<?= $list['name'] ?>" required>
                  <input type="hidden" class="form-control" name="id" value="<?= $list['id'] ?>" required>
                </div>
              </div>
              <div class="form-group">
                <label class="col-sm-2 control-label ">缩略图</label>
                <div class="col-sm-1">
                  <div class="uploadimg" id="uploadimg">
                    <i class="cm-plus"></i>
                    <input type="file" name="share_img" data-id="share-img" class="file-input">
                  </div>
                </div>
                <div class="col-sm-4">
                  <img id="share-img" src="<?= $list['pic'] ?>" style=" width:78px; height:78px;">
                  <span class="tips">尺寸:60x60</span>
                </div>
              </div>

              <div class="form-group"> 
                <label class="col-sm-2 control-label">跳转路径</label>
                <div class="col-sm-4">
                    <select class="form-control link-list-select" onChange="changeType(this)" name="url">
                      <foreach name="select" item="vo">  
                        <option value="{$vo.route}" <if condition="$vo['route'] eq $option">selected</if> >{$vo.name}</option>
                      </foreach>
                        <option value="-1" <if condition="$list['appid']">selected</if> >跳转小程序</option>
                    </select>
                </div>
              </div>
              
              <div class="form-group appid" style="<if condition="!$list['appid']">display: none</if>">
                <label class="col-sm-2 control-label">小程序id</label>
                <div class="col-sm-4">
                  <input type="text" class="form-control" placeholder="请输入appid" name="appid" value=<?= $list['appid'] ?>>
                </div>
              </div>

              <div class="form-group appid" style="<if condition="!$list['appid']">display: none</if>">
                <label class="col-sm-2 control-label">跳转地址</label>
                <div class="col-sm-4">
                  <input type="text" class="form-control" placeholder="例:/pages/index/index?id=123" name="link" value=<?= $list['url'] ?>>
                </div>
              </div>

              <div class="form-group">
                <label class="col-sm-2 control-label">状态</label>
                <div class="col-sm-8">
                  <input type="radio" value="0" name="status" <if condition="$list['status'] eq 0 ">checked</if>> 显示
                  <input type="radio" value="1" name="status" <if condition="$list['status'] eq 1 ">checked</if>> 关闭
                </div>
              </div>

              <div class="form-group">
                <label class="col-sm-2 control-label">排序</label>
                <div class="col-sm-4">
                  <input type="text" class="form-control" value="<?= $list['order_id'] ?>" name="order_id">
                  <div class="text-muted fs-sm">排序越小越靠前</div>
                </div>
              </div>
              
              <div class="form-group">
                <label class="col-sm-2 control-label">首页模式</label>
                <div class="col-sm-4" >
                  <input type="radio" value=1 name="mode" <if condition="$list['mode'] eq 1 ">checked</if> required> 默认模式
                  <input type="radio" value=2 name="mode" <if condition="$list['mode'] eq 2 ">checked</if>> 小店优选
                </div>
              </div>

              <div class="form-group">
                <div class="col-sm-offset-2 col-sm-10">
                  <input type="submit" class="btn btn-primary" value="提交">
                </div>
              </div>
            </form>
          </div>
        </div>
      </div>
    </div>
  </div>

<script>
    function changeType(e) {
      if(e.value==-1){
        $(".appid").show();
      }else{
        $(".appid").hide();
      }
    }

      $('#datetime').datetimepicker({
        format: 'yyyy-mm-dd hh:ii',
        autoclose: true,
        todayBtn: true,
        language: 'zh-CN'
      });
      $("#datetime").on("dp.change", function(e) {
        $('#datetime').data("DateTimePicker").minDate(e.date);
      });
</script>
<script type="text/javascript">
  if (typeof FileReader == 'undefined') {
    $('.uploadimg').html('<h1>当前浏览器不支持FileReader接口</h1>');
  }

  $('.file-input').change(function() {
    var file = this.files[0];
    console.log(file)
    var reader = new FileReader();
    var that = $(this);
    reader.onload = function(e) {
      var img = $('#' + that.attr('data-id'));
      img.attr('src', e.target.result)
    }

    reader.readAsDataURL(file);
  })
</script>
</body>
<include file="Public:upload" />

</html>